package com.linkoog.devtools.json.file_editer.editer.ui;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.TextNode;
import com.linkoog.devtools.utils.JacksonUtil;
import lombok.Getter;
import lombok.ToString;

import javax.swing.tree.DefaultMutableTreeNode;

@Getter
@ToString
public class JackJsonTreeNode extends DefaultMutableTreeNode {

    public final static JackJsonTreeNode DEFAULT = new JackJsonTreeNode("root", new TextNode(""));


    private final String name;
    private final JsonNode jsonNode;
    private final boolean isArrayItem;
    private final String json;


    public JackJsonTreeNode(String name, JsonNode jsonNode) {
       this(name, jsonNode, false);
    }

    public JackJsonTreeNode(String name, JsonNode jsonNode, boolean isArrayItem) {
        this.name = name;
        this.jsonNode = jsonNode;
        this.isArrayItem = isArrayItem;
        this.json = JacksonUtil.toJson(jsonNode);
    }


}
